
function GoogleMapController($scope, FicheManager) {
	var departGPS, arriveeGPS = null;
	var sejourId = parseInt(document.querySelector("#sejourId").value);    

	$('#mapModal').on('shown.bs.modal', function() {
		initialize();
	});

	var initCarteGMapCoordonnees = function () {
		$scope.scFiche = new FicheManager();
        $scope.scFiche.get_coordonnees_gmap( sejourId ).then( function(e) {

            departGPS = e.data.departGPS;
            arriveeGPS = e.data.arriveeGPS;

        });
	}

	var initialize = function () {
		var aDepartGPS = departGPS.split(",");

		var mapCanvas = document.getElementById('map_canvas');
		var myLatLng = new google.maps.LatLng( aDepartGPS[0], aDepartGPS[1]);
		var mapOptions = {
			center: myLatLng,
			zoom: 15,
			mapTypeId: google.maps.MapTypeId.TERRAIN,
			zoomControl: true,
			zoomControlOptions: {
				style: google.maps.ZoomControlStyle.LARGE
			}
		}
		try {
			var image = 'http://www.1001treks.com/img/red-pin-60.png';
			var map = new google.maps.Map(mapCanvas, mapOptions);
			var marker = new google.maps.Marker({
				position: myLatLng,
				map: map,
				title:"We are here",
				icon: image
				
			});
		
		} catch (err) {
			// Error Handling
		}
	}

	initCarteGMapCoordonnees ();
  
}

